<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>问答广场</title>
  <style>
    /* --- 全局和基础样式 (与详情页保持一致) --- */
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
      background-color: #f4f5f7;
      color: #172b4d;
      margin: 0;
      line-height: 1.6;
    }

    .container {
      max-width: 800px;
      margin: 20px auto;
      padding: 0 15px;
    }

    a {
      text-decoration: none;
      color: #007bff;
      transition: color 0.2s;
    }

    a:hover {
      text-decoration: underline;
      color: #0056b3;
    }

    /* 模拟的 Header 占位样式 */
    .header-placeholder {
      background-color: #ffffff;
      padding: 15px 30px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
      margin-bottom: 25px;
      text-align: center;
      font-size: 1.2em;
      font-weight: bold;
      color: #0052cc;
    }

    /* --- 页面头部 --- */
    .page-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 25px;
    }

    .page-header h1 {
      margin: 0;
      font-size: 2.2em;
      color: #091e42;
    }

    /* --- 问题列表卡片样式 --- */
    .question-card {
      background-color: #ffffff;
      border-radius: 8px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
      padding: 20px 25px;
      margin-bottom: 15px;
      transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    }

    .question-card:hover {
      transform: translateY(-4px);
      box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    }

    .question-card h3 {
      margin: 0 0 10px 0;
    }

    .question-card h3 a {
      font-size: 1.3em;
      font-weight: 600;
      color: #091e42;
      text-decoration: none;
    }

    .question-card h3 a:hover {
      color: #007bff;
    }

    .question-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 8px 15px; /* 行间距 和 列间距 */
      font-size: 0.9em;
      color: #6b778c;
      margin: 0;
    }

    .question-meta span {
      display: inline-block;
    }

    /* --- 按钮样式 (与详情页保持一致) --- */
    .btn {
      display: inline-block;
      font-weight: 500;
      text-align: center;
      vertical-align: middle;
      cursor: pointer;
      user-select: none;
      background-color: transparent;
      border: 1px solid transparent;
      padding: 10px 20px;
      font-size: 1em;
      border-radius: 4px;
      transition: all 0.2s ease-in-out;
      text-decoration: none; /* 确保a标签按钮无下划线 */
    }

    .btn:hover {
      text-decoration: none; /* 确保a标签按钮在hover时也无下划线 */
    }

    .btn-primary {
      color: #ffffff;
      background-color: #007bff;
      border-color: #007bff;
    }

    .btn-primary:hover {
      background-color: #0056b3;
      border-color: #0056b3;
      color: #ffffff;
    }
  </style>
</head>
<body>

<div th:replace="~{fragments/header :: header}">
  <div class="header-placeholder">问答社区导航栏</div>
</div>

<div class="container">

  <div class="page-header">
    <h1>问答广场</h1>
    <a href="/qa/ask" class="btn btn-primary">我要提问</a>
  </div>

  <div class="question-list">
    <div th:each="q : ${questions}" class="question-card">
      <h3>
        <a th:href="@{/qa/detail/{id}(id=${q.id})}" th:text="${q.title}">这是一个示例问题标题，点击可以跳转到详情页？</a>
      </h3>
      <p class="question-meta">
        <span class="author" th:text="${q.username}">用户名</span>
        <span>|</span>
        <span><span th:text="${q.commentNum}">5</span> 回答</span>
        <span><span th:text="${q.viewNum}">128</span> 浏览</span>
        <span>发布于 <span th:text="${#temporals.format(q.createTime, 'yyyy-MM-dd')}">2025-06-15</span></span>
      </p>
    </div>

    <div th:if="${#lists.isEmpty(questions)}" class="question-card">
      <p>目前还没有人提问，快去点击右上角的“我要提问”成为第一个吧！</p>
    </div>
  </div>

</div>

</body>
</html>